﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：DapperFrameworkModule.cs
// 功能描述：TongTongMall.MallWeb.DapperFramework
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using Castle.MicroKernel.Registration;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using TongTongMall.Configuration;
using TongTongMall.Dapper;
using TongTongMall.Dapper.Registrar;
using TongTongMall.DapperFramework;
using TongTongMall.DapperFramework.Configuration.Identification;
using TongTongMall.DapperFramework.Configuration.Setting;
using TongTongMall.Dependecy;
using TongTongMall.MallWeb.Core;
using TongTongMall.Modules;

namespace TongTongMall.MallWeb.DapperFramework
{
    [DependsOn(typeof(DapperModule))]
    public class DapperFrameworkModule : BaseModule
    {

        public override void Initialize()
        {

            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

            var repositoryRegistrar = IocManager.IocContainer.Resolve<DapperGenericRepositoryRegistrar>();
            repositoryRegistrar.RegisterForDbContext(typeof(DapperModelSet), IocManager);

            IocManager.Register<IDbProviderFactory, SqlServerDbProviderFactory>();
            //IocManager.IocContainer.Register(Component.For(typeof(IDbProviderFactory)).ImplementedBy(typeof(SqlServerDbProviderFactory)).LifestyleTransient());

            //IocManager.RegisterIfNot<ISettingStore, SqlServerSettingStore>(DependencyLifeStyle.Singleton);

        }

    }
}
